//
//  MessageModel.m
//  HuLaQuan
//
//  Created by liyan on 16/1/18.
//  Copyright © 2016年 yuwubao. All rights reserved.
//

#import "MessageModel.h"

@interface MessageModel()

@property (nonatomic, readwrite) NSString *messageTitle;
@property (nonatomic, readwrite) NSString *messageTime;
@property (nonatomic, readwrite) NSString *messageImage;
@property (nonatomic, readwrite) NSString *messageContent;

@end

@implementation MessageModel
-(instancetype)initWithDictionary:(NSDictionary*) dicObject
{
    if((self = [super init]))
    {
        [self initValuesWithDictionary:dicObject];
    }
    return self;
}
-(void)initValuesWithDictionary:(NSDictionary*) dicObject
{
    [self setValuesForKeysWithDictionary:dicObject];
}
/**
 *  Factory Method
 *
 *  @param dicObject : dictionary of user info including user name and user id
 *
 *  @return Person Object
 */
+(MessageModel *)createUserWithUserInfoDictionary:(NSDictionary*)dicObject
{
    return [[MessageModel alloc] initWithDictionary:dicObject];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
    
    if([key isEqualToString:@"userTitle"])
    {
        //NSLog(@"%@",key);
        self.messageTitle = value;
        // return;
    }
    
    else if([key isEqualToString:@"userTime"])
    {
        self.messageTime = value;
        // return;
    }
    else if([key isEqualToString:@"userImage"])
    {
        self.messageImage = value;
        // return;
    }
    else if([key isEqualToString:@"userContent"])
    {
        self.messageContent = value;
        // return;
    }
    else
    {
        //return;
        [super setValue:value forUndefinedKey:key];
    }
    
}

- (NSString *)description{
    return [NSString stringWithFormat:@"title %@, time %@, image %@, content %@",self.messageTitle,self.messageTime,self.messageImage,self.messageContent];
}
@end
